[1]:
# change cwd to project root
import os
import plotly
import pandas as pd
import numpy as np
import plotly.figure_factory as ff
os.chdir("../../../..")
[2]:
# Imports and notebook setup for parser
from src.midterm import AtlasCountyParser
parser = AtlasCountyParser()
parser.dataFrame = pd.read_csv('src/midterm/data/initial_model.csv',index_col=0)
plotly.offline.init_notebook_mode()
Number of counties in the US¶
counting the number of counties that are analyzed within the data
[58]:
parser.dataFrame.index.size
[58]:
3210
Food Desert Counties¶
counting the number of counties that are marked as food deserts by the USDA Model
[38]:
parser.dataFrame['USDA Model'].sum()
[38]:
568
Visualization¶
using plotly we can look at a visual representation of what counties are food deserts within the continental US. > red = Food Desert
[59]:
scl = ["#0000FF","#ff0000"]
endpts = list(np.linspace(0,1,len(scl) -1))
fips = parser.dataFrame.index.tolist()
values= parser.dataFrame["USDA Model"].tolist()
fig = ff.create_choropleth(
fips=fips, values=values, scope=['usa'],
binning_endpoints=endpts,
colorscale=scl,
show_state_data=False,
show_hover=False, centroid_marker={'opacity':0},
asp=2.9, title="Food Deserts"
)
plotly.offline.iplot(fig, filename='choropleth_full_usa')
/usr/local/lib64/python3.6/site-packages/pandas/core/frame.py:6692: FutureWarning:
Sorting because non-concatenation axis is not aligned. A future version
of pandas will change to not sort by default.
To accept the future behavior, pass 'sort=False'.
To retain the current behavior and silence the warning, pass 'sort=True'.
[ ]: